import * as API_liveKit from '@/api/livekit'
import store from '@/store'
// import bus from '@/utils/bus'

// dom 渲染媒体内容
export const renderMedia = (id, media, kind, isScreenShareEnabled) => { // id,媒体标签， 媒体类型
	media.style.setProperty('object-fit', 'cover', 'important');
	media.style.setProperty('width', '100%', 'important');
	media.style.setProperty('height', '100%', 'important');
    if (isScreenShareEnabled) {
        document.getElementById(id + '_screen').innerHTML = ''
        document.getElementById(id + '_screen').appendChild(media)
    } else {
        document.getElementById(id + '_' + kind).innerHTML = ''
        document.getElementById(id + '_' + kind).appendChild(media)
    }
}
// 快速会议呼叫
export const handleCallMeet = async (params) => { // 快速会议呼叫
    await API_liveKit.callMeet(params) //  呼叫
    // await API_liveKit.callMeetAgain(params) //  呼叫
}
// 快速会议呼叫
export const handleCallMeetAgain = async (params) => { // 快速会议呼叫
    // await API_liveKit.callMeet(params) //  呼叫
    await API_liveKit.callMeetAgain(params) //  呼叫
}
export const stopCallBack = async (data) => {
    resetData(data)
}


const resetData = (data) => {
	
	data.naviTo('index/index',{},2);
	
}
export const getCurrentDate = () => {
    var currentDate = new Date();
    var year = currentDate.getFullYear();
    var month = (currentDate.getMonth() + 1).toString().padStart(2, '0');
    var day = currentDate.getDate().toString().padStart(2, '0');
    var hour = currentDate.getHours().toString().padStart(2, '0');
    var minute = currentDate.getMinutes().toString().padStart(2, '0');
    var second = currentDate.getSeconds().toString().padStart(2, '0');

    var formattedDate = `${year}-${month}-${day} ${hour}:${minute}:${second}`;
    return formattedDate
}